<template>
  <hips-view>
    <hips-nav-bar
      slot="header"
      title="SwitchCell 单元格开关"
      :back-button="{
        showLeftArrow: true,
      }"
      @nav-bar-back-click="$router.back()"
    />

    <hips-tabs
      slot="sub-header"
      v-model="active"
    >
      <hips-tab title="标准用法" />
      <hips-tab title="Dsx用法" />
    </hips-tabs>

    <div v-show="!active">
      <demo-block title="基础用法">
        <hips-group>
          <hips-switch-cell
            v-model="checked"
            title="标题"
          />          
        </hips-group>
      </demo-block>

      <demo-block title="禁用">
        <hips-group>
          <hips-switch-cell
            v-model="checked1"
            title="标题"
            disabled
          />
        </hips-group>
      </demo-block>

      <demo-block title="加载状态">
        <hips-group>
          <hips-switch-cell
            v-model="checked2"
            title="标题"
            loading
          />
        </hips-group>
      </demo-block>
    </div>
    <div v-show="active">
      <demo-block title="基础用法">
        <hips-group>
          <hips-switch-cell :d-field="dsx.records.at(0).getField('checked')" />          
        </hips-group>
      </demo-block>

      <demo-block title="禁用">
        <hips-group>
          <hips-switch-cell :d-field="dsx.records.at(0).getField('checked1')" />
        </hips-group>
      </demo-block>

      <demo-block title="加载状态">
        <hips-group>
          <hips-switch-cell :d-field="dsx.records.at(0).getField('checked2')" />
        </hips-group>
      </demo-block>
    </div>
  </hips-view>
</template>

<script>
import BasicView from '@/mixin/basic-view';
import { SwitchCell, Group, Tabs, Tab } from '@hips/vue-ui';
import Dsx from '@hips/plugin-dataset-vuex';

export default {
  components: {
    [SwitchCell.name]: SwitchCell,
    [Group.name]: Group,
    [Tabs.name]: Tabs,
    [Tab.name]: Tab,
  },
  mixins: [ BasicView ],
  data() {
    return {
      active: 0,
      checked: true,
      checked1: false,
      checked2: true,
      dsx: new Dsx({
        moduleName: 'dsx-switch-cell',
        autoCreate: true,
        fields: [
          {
            name: 'checked',
            defaultValue: true,
            title: '标题',
          },
          {
            name: 'checked1',
            defaultValue: false,
            disabled: true,
            title: '标题',
          },
          {
            name: 'checked2',
            defaultValue: true,
            loading: true,
            title: '标题',
          },
        ],
      }),
    };
  },
};
</script>
